<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    :footer="null"
    @cancel="visible=false">
    <a-card :bordered="false">
      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <a-button @click="handleAdd" type="primary" icon="plus">出租</a-button>
      </div>

      <!-- table区域-begin -->
      <div>
        <a-table
          ref="table"
          size="middle"
          :scroll="{x:true}"
          bordered
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :loading="loading"
          class="j-table-force-nowrap"
          @change="handleTableChange">
          <span slot="action" slot-scope="text, record">
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                <a>删除</a>
            </a-popconfirm>
          </span>
        </a-table>
      </div>
      <vca-farmland-rent-modal ref="modalForm" @ok="modalFormOk"></vca-farmland-rent-modal>
    </a-card>
  </j-modal>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import VcaFarmlandRentModal from './modules/VcaFarmlandRentModal'

  export default {
    name: 'VcaFarmlandRentList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      VcaFarmlandRentModal
    },
    data () {
      return {
        visible:false,
        disableMixinCreated:true,
        width:600,
        title:'',
        description: 'vca_farmland_rent管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'租户',
            align:"center",
            dataIndex: 'rentName'
          },
          {
            title:'出租面积',
            align:"center",
            dataIndex: 'rentArea'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/villageCadreAssist/vcaFarmlandRent/list",
          delete: "/villageCadreAssist/vcaFarmlandRent/delete"
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {

    },
    watch:{
      'dataSource.length':{
        handler(newValue, oldValue) {
          this.$emit('ok');
        }
      }
    },
    methods: {
      initDictConfig(){
      },
      handleAdd: function () {
        this.$refs.modalForm.add(this.model);
        this.$refs.modalForm.title = "土地出租";
        this.$refs.modalForm.disableSubmit = false;
      },
      // modalFormOk: function(){
      //   this.$emit('ok');
      // },
      view(record){
        this.model = Object.assign({},record)
        this.queryParam.ownId = record["id"];
        this.loadData();
        this.visible=true;
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'int',value:'ownId',text:'ownId',dictCode:''})
        fieldList.push({type:'int',value:'rentId',text:'rentId',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'rentArea',text:'rentArea',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>